﻿
using Order.Application.Data;

namespace Ordering.Infrastructure.Data
{
    public class ApplicationDbContext: DbContext, IApplicationDbcontext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
        {
        }

        public DbSet<Ordering.Domain.Models.Order> Orders => Set<Ordering.Domain.Models.Order>();

        public DbSet<Customer> Customers => Set<Customer>();

        public DbSet<OrderItem> OrderItems => Set<OrderItem>();

        public DbSet<Product> Products => Set<Product>();

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //自动应用IEntityTypeConfiguration<TEntity>的接口实现关系配置
            modelBuilder.ApplyConfigurationsFromAssembly(typeof(ApplicationDbContext).Assembly);
            base.OnModelCreating(modelBuilder);
        }

    }
}
